/**
 * Copyright (c) 2015 www.smarthome.com All rights reserved. <br />
 * 本软件源代码版权归xxxx公司,未经许可不得任意复制与传播.<br />
 *
 */
package com.smarthome.domain.enums;

/**
 * 设备类型--枚举类
 *
 */
public enum EquipmentTypeEnum {
    /*** 摆闸 ***/
    DEV_SWING("swing", "摆闸"),
    /*** 门口机/对讲 ***/
    DEV_TALK("talk", "门口机/对讲"),
    /*** 监控设备 ***/
    DEV_CAMERA("camera", "监控设备"),
    /*** 工控机 ***/
    DEV_IPC("ipc", "工控机");

    private String code;
    private String name;

    private EquipmentTypeEnum(String code, String name) {
        this.code = code;
        this.name = name;

    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    /**
     * 通过id，得到名称
     * @param code
     * @return
     */
    public static String getNameByCode(String code) {
        String name = "";
        for (EquipmentTypeEnum e : EquipmentTypeEnum.values()) {
            if (e.getCode().equals(code)) {
                name = e.getName();
                break;
            }
        }
        return name;
    }

}
